//
//  MessageViewController.swift
//  HR
//
//  Created by zhenyu on 17/6/24.
//  Copyright © 2017年 allblue. All rights reserved.
//

import UIKit


class MessageViewController: ViewController {
  
  weak var tableView: UITableView!
  var tableHeaderView = HomeHeader(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: 132))
  
  // MARK: - LifeCycle
  override func viewDidLoad() {
    super.viewDidLoad()
    setViews()
    // Do any additional setup after loading the view.
    
    title = "消息列表"
  }
  
  override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
  }
  
  
  // MAKR: - SetViews
  func setViews() {
    
    tableView = {
      let t = UITableView(frame: CGRect(x: 0, y: 0, width: view.width, height: view.height - 64 - 48), style: .plain)
      view.addSubview(t)
      t.backgroundColor = Color.back
      t.rowHeight = UITableViewAutomaticDimension
      t.estimatedRowHeight = 100
      t.separatorColor = Color.line
      
      t.showsVerticalScrollIndicator = false
      t.delegate = self
      t.dataSource = self
      t.separatorStyle = .none
      t.register(MessageCell.self, forCellReuseIdentifier: MessageCell.identifier())
      return t
    }()
  }
}


// MARK: - UITableViewDelegate, UITableViewDataSource
extension MessageViewController: UITableViewDelegate, UITableViewDataSource {
  func numberOfSections(in tableView: UITableView) -> Int {
    return 1
  }
  
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 2
  }
  
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: MessageCell.identifier(), for: indexPath) as! MessageCell
    return cell
  }
  
  
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    
  }
}
